<!DOCTYPE html>
<html>
<head>
  <title>登录</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/popper.js/1.12.5/umd/popper.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
<div class="col-sm-5"></div>
<div class="col-sm-4"><h1>登录</h1></div>
<div class="col-sm-3"></div>
</div>

<div class="row">
  <div class="col-sm-3"></div>
 	 <div class="col-sm-6">
		<form >
		  <div class="form-group">
		    <label for="email">用户名:</label>
		    <input type="text" class="form-control" id="email" name="uname">
		  </div>
		  <div class="form-group">
		    <label for="pwd">密码:</label>
		    <input type="password" class="form-control" id="pwd" name="password">
		  </div>
		 <button type="button" id="subbtn" class="btn btn-primary">登录</button>
		  <a href="register.html" class="btn btn-success">还没有账号？注册一个</a>
		</form>
	 </div>
	 
	  <div class="col-sm-3"></div>
</div>
<script type="text/javascript">

$(document).ready(function(){
	$("#subbtn").click( function () { 
		var uval=$("#email").val();
		var pval=$("#pwd").val();
		
		$.getJSON("LoginServlet", { uname: uval,password:pval }, function(json){
			  console.log(json);
			  var url=json.result;
			  if("fail.html"==url){
				  alert("用户名或者密码错误！");
			  }else{
				//window.location.href跳转到
				  window.location.href=url; 
			  }
			  
			  
			});
	} );
} );
</script>
</body>
</html>